package com.entidades.bdd;


import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;


@Entity
@Table(name = "Family")
@NamedQuery(name = "Family.findAll", query = "SELECT c FROM Family c")
public class Family extends BaseObject implements Serializable {
	
	/**
     * 
     */
	private static final long serialVersionUID = 34566L;
	
	
	private String description;
	
	
	@OneToMany(mappedBy = "family")
	private List<Person> members = new ArrayList<Person>();
	
	public String getDescription() {
		return description;
	}
	
	public void setDescription(String description) {
		this.description = description;
	}
	
	
	public List<Person> getMembers() {
		return members;
	}
	
	public void setMembers(List<Person> members) {
		this.members = members;
	}
	
	@Override
	public String toString() {
		return "Family [id=" + getId() + ", description=" + description + ", members=" + members.size() + "]";
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Family))
			return false;
		if (getId() != ((BaseObject) obj).getId())
			return false;
		return true;
	}
}
